//
//  CallBackDateCell.swift
//  d11
//
//  Created by peale_pro on 2019/10/16.
//  Copyright © 2019 Tech_001. All rights reserved.
//

import UIKit


class CallBackDateCell: UITableViewCell {
    var titleLabel : UILabel?
    var bgBtn: UIButton?
    var iconImgView :UIImageView?
    var dateLabel :UILabel?
    var titleLabel2 : UILabel?
    var timeBgBtn : UIButton?
    var timeIconImgView1 :UIImageView?
    var startTimeLabel :UILabel?
    var fuhaoLabel :UILabel?
     var endtimeBgBtn : UIButton?
    var timeIconImgView2 :UIImageView?
       var endTimeLabel :UILabel?
     var hintLabel : UILabel?
    var dateTextField: SelectionTextField!
   
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCell.SelectionStyle.none
        self.setUpUI()

    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    func setUpUI() -> Void {
        self.titleLabel = UILabel.init()
           self.titleLabel?.font = UIFont.systemFont(ofSize: 14)
           self.titleLabel?.text = "方便回拨日期:"
           self.titleLabel?.textAlignment = .left
           self.titleLabel?.textColor = HexRGBAlpha(0x444444, 1)
           self.contentView.addSubview(self.titleLabel!)
            self.titleLabel?.snp.makeConstraints{(make) in
                make.left.equalToSuperview().offset(12)
                make.width.equalTo(130)
                make.height.equalTo(20)
                make.top.equalToSuperview().offset(10)
            }
        self.bgBtn = UIButton.init(type: .custom)
        self.bgBtn?.layer.cornerRadius = 4
        self.bgBtn?.layer.masksToBounds = true
        self.bgBtn?.layer.borderColor = HexRGBAlpha(0x888888, 1).cgColor
        self.bgBtn?.layer.borderWidth = 1
        self.contentView.addSubview(self.bgBtn!)
        self.bgBtn?.snp.makeConstraints{(make) in
            make.left.equalToSuperview().offset(12)
            make.width.equalTo(120)
            make.height.equalTo(40)
            make.top.equalTo((self.titleLabel?.snp.bottom)!)
        }
        self.iconImgView = UIImageView.init(image: UIImage.init(named: "icon_kefu_submit_calendar"))
        self.bgBtn?.addSubview(self.iconImgView!)
        self.iconImgView?.snp.makeConstraints{(make) in
            make.left.equalToSuperview().offset(4)
            make.width.equalTo(15)
            make.height.equalTo(14)
            make.centerY.equalToSuperview()
        }
 
     
        
         let cdate = Date()
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd"
         let dateStr = formatter.string(from: cdate)
        self.dateLabel = UILabel.init()
         self.dateLabel?.text = dateStr
        self.dateLabel?.font = UIFont.systemFont(ofSize: 13)
        self.dateLabel?.textAlignment = .center
        self.dateLabel?.textColor = HexRGBAlpha(0x444444, 1)
        self.bgBtn?.addSubview(self.dateLabel!)
         self.dateLabel?.snp.makeConstraints{(make) in
             make.left.equalTo((self.iconImgView?.snp.right)!).offset(-10)
             make.right.equalToSuperview()
             make.height.equalTo(20)
             make.top.equalToSuperview().offset(10)
         }
        self.titleLabel2 = UILabel.init()
        self.titleLabel2?.font = UIFont.systemFont(ofSize: 14)
        self.titleLabel2?.text = "方便回拨时间:"
        self.titleLabel2?.textAlignment = .left
        self.titleLabel2?.textColor = HexRGBAlpha(0x444444, 1)
        self.contentView.addSubview(self.titleLabel2!)
         self.titleLabel2?.snp.makeConstraints{(make) in
            make.left.equalTo((self.bgBtn?.snp.right)!).offset(20)
             make.width.equalTo(100)
             make.height.equalTo(20)
             make.top.equalToSuperview().offset(10)
         }

        self.timeBgBtn = UIButton.init(type: .custom)
        self.timeBgBtn?.layer.cornerRadius = 4
        self.timeBgBtn?.layer.masksToBounds = true
        self.timeBgBtn?.layer.borderColor = HexRGBAlpha(0x888888, 1).cgColor
        self.timeBgBtn?.layer.borderWidth = 1
        self.contentView.addSubview(self.timeBgBtn!)
        if(UIScreen.main.bounds.size.height == 568){
            self.timeBgBtn?.snp.makeConstraints{(make) in
                make.left.equalTo((self.titleLabel2?.snp.left)!)
                make.width.equalTo(75)
                make.height.equalTo(40)
                make.top.equalTo((self.titleLabel2?.snp.bottom)!)
            }
        }else{
        self.timeBgBtn?.snp.makeConstraints{(make) in
            make.left.equalTo((self.titleLabel2?.snp.left)!)
            make.width.equalTo(80)
            make.height.equalTo(40)
            make.top.equalTo((self.titleLabel2?.snp.bottom)!)
        }
        }
        self.timeIconImgView1 = UIImageView.init(image: UIImage.init(named: "icon_kefu_submit_time"))
        self.timeBgBtn?.addSubview(self.timeIconImgView1!)
        self.timeIconImgView1?.snp.makeConstraints{(make) in
            make.left.equalToSuperview().offset(6)
            make.width.equalTo(15)
            make.height.equalTo(14)
            make.centerY.equalToSuperview()
        }
      
        let dateformatter = DateFormatter()
        dateformatter.dateFormat = "HH:mm:ss"// 自定义时间格式
        let time = dateformatter.string(from: Date())
       
        self.startTimeLabel = UILabel.init()
        self.startTimeLabel?.text = time
        self.startTimeLabel?.font = UIFont.systemFont(ofSize: 12)
        self.startTimeLabel?.textAlignment = .center
        self.startTimeLabel?.textColor = HexRGBAlpha(0x444444, 1)
        self.timeBgBtn?.addSubview(self.startTimeLabel!)
         self.startTimeLabel?.snp.makeConstraints{(make) in
            make.left.equalTo((self.timeIconImgView1?.snp.right)!)
            make.right.equalToSuperview()
             make.height.equalTo(20)
             make.top.equalToSuperview().offset(10)
         }
        
        self.fuhaoLabel = UILabel.init()
        self.fuhaoLabel?.font = UIFont.systemFont(ofSize: 14)
        self.fuhaoLabel?.text = " ~ "
        self.fuhaoLabel?.textAlignment = .center
        self.fuhaoLabel?.textColor = HexRGBAlpha(0x444444, 1)
        self.contentView.addSubview(self.fuhaoLabel!)
         self.fuhaoLabel?.snp.makeConstraints{(make) in
            make.left.equalTo((self.timeBgBtn?.snp.right)!)
             make.width.equalTo(20)
             make.height.equalTo(20)
            make.centerY.equalTo((self.timeBgBtn?.snp.centerY)!)
         }
        
        self.endtimeBgBtn = UIButton.init(type: .custom)
        self.endtimeBgBtn?.layer.cornerRadius = 4
        self.endtimeBgBtn?.layer.masksToBounds = true
        self.endtimeBgBtn?.layer.borderColor = HexRGBAlpha(0x888888, 1).cgColor
        self.endtimeBgBtn?.layer.borderWidth = 1
        self.contentView.addSubview(self.endtimeBgBtn!)
        if(UIScreen.main.bounds.size.height == 568){
        self.endtimeBgBtn?.snp.makeConstraints{(make) in
            make.left.equalTo((self.fuhaoLabel?.snp.right)!)
            make.width.equalTo(70)
            make.height.equalTo(40)
            make.top.equalTo((self.titleLabel2?.snp.bottom)!)
            }
            
        }else{
            self.endtimeBgBtn?.snp.makeConstraints{(make) in
                make.left.equalTo((self.fuhaoLabel?.snp.right)!)
                make.width.equalTo(80)
                make.height.equalTo(40)
                make.top.equalTo((self.titleLabel2?.snp.bottom)!)
            }
        }
        self.endTimeLabel = UILabel.init()
        self.endTimeLabel?.text = "结束时间"
        self.endTimeLabel?.font = UIFont.systemFont(ofSize: 12)
        self.endTimeLabel?.textAlignment = .center
        self.endTimeLabel?.textColor = HexRGBAlpha(0x444444, 1)
        self.endtimeBgBtn?.addSubview(self.endTimeLabel!)
         self.endTimeLabel?.snp.makeConstraints{(make) in
            make.left.equalToSuperview()
            make.right.equalToSuperview()
             make.height.equalTo(20)
             make.top.equalToSuperview().offset(10)
         }
        self.hintLabel = UILabel.init()
        self.hintLabel?.font = UIFont.systemFont(ofSize: 12)
        self.hintLabel?.text = ""
        self.hintLabel?.textAlignment = .left
        self.hintLabel?.textColor = HexRGBAlpha(0x444444, 1)
        self.contentView.addSubview(self.hintLabel!)
        self.hintLabel?.snp.makeConstraints{(make) in
            make.left.equalToSuperview().offset(12)
            make.right.equalToSuperview().offset(-12)
            make.height.equalTo(20)
            make.top.equalTo((self.bgBtn?.snp.bottom)!)
        }
    }
}
